package com.dome.mvp.adapter;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.PagerAdapter;

import com.dome.mvp.R;
import com.dome.mvp.base.BaseAdapter;
import com.dome.mvp.base.BaseViewHolder;
import com.dome.mvp.bean.MainBean;
import com.dome.mvp.databinding.AdapterMainBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * Time: 6/1/2021 8:51
 * Author: TAO
 * Description:
 */
public class MainAdapter extends FragmentPagerAdapter {


    private List<Fragment> list = new ArrayList<>();

    public MainAdapter(@NonNull FragmentManager fm, int behavior) {
        super(fm, behavior);
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    public void setList(List<Fragment> list) {
        this.list.addAll(list);
        notifyDataSetChanged();
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
//        super.destroyItem(container, position, object);
    }
}
